﻿#ifndef __PARAMETER_H
#define __PARAMETER_H

// ==================== 包含的头文件 ====================
#include <stdio.h>
#include "ipp.h"
#include <fstream>
#include <cstring>
#include <cstdlib>

// ==================== 系统变量宏定义 ====================
#define g_fl      2000
#define g_fh      4000
#define g_f0      (g_fh+g_fl)/2
#define g_Bs      (g_fh-g_fl)
#define g_fs      32000
#define N_upsample 32
#define N_samp_SIMO        202  // 训练序列长度，原本为152，4/12改动
#define Tg  0.1 
#define N_g 100

#define g_Syn_NFFT                  512  // 多通道已改，5/12改动
#define g_Syn_NFFT_RAW              16384  // 多通道已改 
#define g_LFM2Data_Delay            16384  // 原来的扩频码函数用的，目前不用管
#define g_LFM2Data_lenth            8192
#define g_Syn_BufCnt                8192        
#define g_SamStep                   1        
#define g_Syn_BufSamCnt             (g_Syn_BufCnt/g_SamStep)        
#define g_Syn_CacheNFFT             32768  // 原来的扩频码函数用的，目前不用管

#define g_InfoSamPointTotalSyn      101216  // 140304  // 134544  // 4.12改为151824
#define g_N_Block                   5
#define g_block_num                 5

#define Signal_After_Noise_lenth    167199  // 4.12新增
#define Signal_After_BP_lenth       Signal_After_Noise_lenth  // 187055//原本是182319
#define DelayLen                    3200
#define phi_size                    180
#define SNR_CONST                   6.30957  // 信噪比，外界给出，一般为10^(8/10)
#define channel_num_CONST           4

#define g_N_AllBlockDataBit         1050  // 5/12改动 1050  // 4/12改动
#define g_N_PilotDataBit            404  // 4/12改动
#define g_SymbolTxMatrix_len        2060  // 4/12改动

#define g_InfoBitNumTotalPerFrame   500
#define g_r                         5
#define g_InfoSymbolNumPerFrame     100
#define g_PolitSymbolDecSize        2
#define g_SpreadCodeLen             32
#define g_TotalSymbolNumPerFrame    102
#define g_UpSamplingMultiple        240

// ==================== 导出变量 ====================
    extern Ipp32s g_PolitSymbolDec[2];
    extern Ipp32fc Syn_FIRCoe_SC[193];
    extern Ipp32fc Syn_FIRCoe_SC_BANDPASS[513];
    extern Ipp32s Syn_FIRLen;
    extern Ipp32s Syn_FIRLen_BANDPASS;
    extern Ipp32u MaxCacheFrameCnt;
    extern Ipp32f Syn_Threshold;

    extern Ipp32fc Table[4];
    extern Ipp32fc Syn_RefCopyAll[8192];
    extern Ipp32fc g_SymbolTxMatrix[2060];
    extern Ipp32fc PulseShape_PSK[33];
    extern Ipp32s PulseShape_PSK_Len;

    extern Ipp32fc BandPass_PSK[513];
    extern Ipp32s BandPass_PSK_Len;
    extern Ipp32fc Syn_RefCopySam[16384];
    extern Ipp32u g_Sort_Table[2100];

    // ==================== 短帧参数 ====================
#define SF_g_fl      2000
#define SF_g_fh      4000
#define SF_g_f0      (SF_g_fh+SF_g_fl)/2
#define SF_g_Bs      (SF_g_fh-SF_g_fl)
#define SF_g_fs      32000
#define SF_N_upsample 32
#define SF_N_samp_SIMO        65  // 训练序列长度，原本为152，4/12改动
#define SF_Tg  0.032 
#define SF_N_g 32

#define SF_g_Syn_NFFT                  256  // 多通道已改，5/12改动
#define SF_g_Syn_NFFT_RAW              16384  // 多通道已改 
#define SF_g_LFM2Data_Delay            16384  // 原来的扩频码函数用的，目前不用管
#define SF_g_LFM2Data_lenth            8192
#define SF_g_Syn_BufCnt                8192        
#define SF_g_SamStep                   1        
#define SF_g_Syn_BufSamCnt             (SF_g_Syn_BufCnt/SF_g_SamStep)        
#define SF_g_Syn_CacheNFFT             32768  // 原来的扩频码函数用的，目前不用管

#define SF_g_InfoSamPointTotalSyn      10336  // 140304  // 134544  // 4.12改为151824
#define SF_g_N_Block                   1
#define SF_g_block_num                 3

#define SF_Signal_After_Noise_lenth    129119  // 4.12新增
#define SF_Signal_After_BP_lenth       SF_Signal_After_Noise_lenth  // 187055//原本是182319
#define SF_DelayLen                    1600
#define SF_phi_size                    180
#define SF_SNR_CONST                   6.30957  // 信噪比，外界给出，一般为10^(8/10)
#define SF_channel_num_CONST           4

#define SF_g_N_AllBlockDataBit         159  // 5/12改动 1050  // 4/12改动
#define SF_g_N_PilotDataBit            130  // 4/12改动
#define SF_g_SymbolTxMatrix_len        224  // 4/12改动

// 短帧导出变量
    extern Ipp32fc SF_Syn_FIRCoe_SC[193];
    extern Ipp32fc SF_Syn_FIRCoe_SC_BANDPASS[513];
    extern Ipp32s SF_Syn_FIRLen;
    extern Ipp32s SF_Syn_FIRLen_BANDPASS;
    extern Ipp32u SF_MaxCacheFrameCnt;
    extern Ipp32f SF_Syn_Threshold;

    extern Ipp32fc SF_Table[4];
    extern Ipp32fc SF_Syn_RefCopyAll[8192];
    extern Ipp32fc SF_g_SymbolTxMatrix[224];
    extern Ipp32fc SF_PulseShape_PSK[33];
    extern Ipp32s SF_PulseShape_PSK_Len;

    extern Ipp32fc SF_BandPass_PSK[513];
    extern Ipp32s SF_BandPass_PSK_Len;
    extern Ipp32fc SF_Syn_RefCopySam[16384];
    extern Ipp32u SF_g_Sort_Table[318];

    // ==================== 时域均衡参数 ====================
#define TDE_g_fl      2000
#define TDE_g_fh      4000
#define TDE_g_f0      (TDE_g_fh+TDE_g_fl)/2
#define TDE_N_upsample 48
#define TDE_BandPass_len              513
#define TDE_g_Syn_BufCnt              16384
#define TDE_g_SamStep                 1        
#define TDE_g_Syn_BufSamCnt           (TDE_g_Syn_BufCnt/TDE_g_SamStep)        
#define TDE_g_Syn_NFFT_RAW            32768
#define TDE_g_InfoSamPointTotalSyn    96000
#define TDE_g_LFM2Data_lenth          16384
#define TDE_g_fs                      32000
#define TDE_DelayLen                  0.25*TDE_g_fs
#define TDE_Signal_After_Noise_lenth  TDE_g_fs * 2 + TDE_g_LFM2Data_lenth * 2 + TDE_g_InfoSamPointTotalSyn
#define TDE_Signal_After_BP_lenth     TDE_Signal_After_Noise_lenth

#define TDE_channel_num               4
#define TDE_n1                        60
#define TDE_n2                        120
#define TDE_Delta                     0.5
#define TDE_Lambda                    0.9985
#define TDE_PLL1                      0.00001
#define TDE_PLL2                      0.000001
#define TDE_user_num                  2000
#define TDE_bitnum_per                2
#define TDE_N_samp                    500
#define TDE_Table_size                4
#define TDE_NFFT                      1000
#define TDE_NFFT_UW                   500

// 时域均衡导出变量
    extern Ipp32u TDE_MaxCacheFrameCnt;
    extern Ipp32f TDE_Syn_Threshold;
    extern Ipp32fc TDE_BandPass[513];
    extern Ipp32fc TDE_SignalHFM[16384];
    extern Ipp32fc TDE_SignalHFM_FFT[32768];
    extern Ipp32fc TDE_PulseShape[289];
    extern Ipp32s TDE_PulseShape_len;
    extern Ipp32u TDE_g_Sort_Table[2000];

    // ==================== 扩频参数 ====================
#define MA_g_fl      2000
#define MA_g_fh      4000
#define MA_g_f0      (MA_g_fh+MA_g_fl)/2
#define MA_g_Bs      (MA_g_fh-MA_g_fl)
#define MA_g_fs      32000


#define MA_g_Syn_NFFT                  256  
#define MA_g_Syn_NFFT_RAW              16384  // 多通道已改 
#define MA_g_LFM2Data_Delay            16384  // 原来的扩频码函数用的，目前不用管
#define MA_g_LFM2Data_lenth            8192
#define MA_g_Syn_BufCnt                8192        
#define MA_g_SamStep                   1        
#define MA_g_Syn_BufSamCnt             (SF_g_Syn_BufCnt/SF_g_SamStep)        
#define MA_g_Syn_CacheNFFT             32768  // 原来的扩频码函数用的，目前不用管

#define MA_g_InfoSamPointTotalSyn      2432  
#define MA_g_N_Block                   1
#define MA_g_block_num                 3

#define MA_Signal_After_Noise_lenth    119615  
#define MA_Signal_After_BP_lenth       MA_Signal_After_Noise_lenth  
#define MA_DelayLen                    4096
#define MA_phi_size                    180
#define MA_SNR_CONST                   6.30957  // 信噪比，外界给出，一般为10^(8/10)
#define MA_channel_num_CONST           4

#define MA_g_N_AllBlockDataBit         159 
#define MA_g_N_PilotDataBit            130  
#define MA_g_SymbolTxMatrix_len        224  
#define Mass_FIRCoe_len                65


#define g_UpSamplingMultiple_Mass               19      //升采样倍数
#define g_InfoSymbolNumPerFrame_Mass            2     //每帧发送信息符号数
#define g_PolitSymbolUsed_Mass                  2       //用到的导频数
#define g_SpreadCodeLen_Mass                    32      //扩频码长度
#define g_M_Mass                                32      //用到的扩频码数目
#define g_SlidingInterval_Mass                  2       //滑动窗大小
#define g_PolitSymbolNumPerFrame_Mass           2       //每帧的导频符号数
#define g_TotalSymbolNumPerFrame_Mass           (g_InfoSymbolNumPerFrame_Mass+g_PolitSymbolNumPerFrame_Mass) //每帧总发送符号
#define g_r_Mass                                5       //每个扩频码调制的信息量（bits）
#define g_InfoBitNumTotalPerFrame_Mass          g_r_Mass*g_InfoSymbolNumPerFrame_Mass //每帧的信息bit数
// 扩频导出变量
    extern Ipp32u  MA_MaxCacheFrameCnt;
    extern Ipp32f  MA_Syn_Threshold;
    extern Ipp32fc MA_Syn_FIRCoe_SC_BANDPASS[513];
    extern Ipp32fc MA_Syn_RefCopyAll[8192];
    extern Ipp32fc MA_Syn_RefCopySam[16384];
    extern Ipp32fc Mass_FIRCoe[65];
    //Mass算法的导频数组,已被开放出来
    extern Ipp32fc PolitSig[g_PolitSymbolUsed_Mass * g_SpreadCodeLen_Mass];
    extern  Ipp32fc DeSpreadCode[32][g_SpreadCodeLen_Mass];                //Mass算法解码用的扩频码矩阵





//MIMO_QPSK参数
// QPSK信号生成相关常数定义
#define MQPSK_fs            200000      // 采样频率 (100kHz)
#define MQPSK_f0_1          10000       // 载波频率 (10kHz)
#define MQPSK_f0_2          14000       // 载波频率 (10kHz)
#define MQPSK_R_s1          2500        // 有效符号速率 (2.5kHz)
#define MQPSK_alpha_1       0.2f        // 滚降系数
#define MQPSK_M             4           // 调制阶数
#define MQPSK_bitnum_per    2           // 每符号比特数 (QPSK)
#define MQPSK_Sym_time      10.0f       // 有效符号持续时间 (秒)
#define MQPSK_Numburst      1           // 突发数量
#define MQPSK_Numblock_perburst 1       // 每突发块数
#define N_pn              80
#define MQPSK_p_1_length    1601
#define MQPSK_N             150
#define MQPSK_g_fl      6000
#define MQPSK_g_fh      8000
#define MQPSK_g_f0      (MQPSK_g_fh+SF_g_fl)/2
#define MQPSK_data_length 11500
#define MQPSK_signal_send_1 905536
#define MQPSK_Numsym_perblock   6750
//同步相关参数
#define QPSK_g_Syn_BufCnt      32768
#define QPSK_g_Syn_NFFT_RAW    65536
#define QPSK_g_InfoSamPointTotalSyn  540000
#define QPSK_g_SamStep                   1        
#define QPSK_g_Syn_BufSamCnt             (QPSK_g_Syn_BufCnt/QPSK_g_SamStep)      
#define QPSK_Signal_After_Noise_lenth    905536  
#define QPSK_Signal_After_BP_lenth       QPSK_Signal_After_Noise_lenth 
#define QPSK_g_LFM2Data_lenth            32768
#define QPSK_DelayLen                    50000
#define train_sequence_len               1000
//MDFE均衡相关参数
#define MQPSK_channel_num   16
#define QPSK_L1                         40
#define QPSK_L2                         40  
#define QPSK_Delta                      0.5
#define QPSK_Lambda                     0.9995
#define QPSK_PLL1                      0.0001
#define QPSK_PLL2                      0.00001
#define QPSK_Bitnum_per                2
#define QPSK_N_Samp                    1000

    extern Ipp32f  MQPSK_p_1[1601];
    extern Ipp32fc Syn_RefCopyAll_QPSK[32768];
    extern Ipp32fc Syn_RefCopyAll_QPSK_2[32768];
    extern Ipp32fc Syn_RefCopySam_QPSK[65536];
    extern Ipp32fc Syn_RefCopySam_QPSK_2[65536];
    extern Ipp32f Syn_Threshold_QPSK;
    extern Ipp32fc Syn_FIRCoe_SC_BANDPASS_QPSK_2[513];
    extern Ipp32fc Syn_FIRCoe_SC_BANDPASS_QPSK[513];
    extern Ipp32s  Syn_FIRLen_BANDPASS_QPSK;
    extern Ipp32u  MaxCacheFrameCnt_QPSK;
    extern Ipp32fc train_sequence[1000];

    




//6-8k滤波器参数
    extern Ipp32fc Syn_FIRCoe_SC_BANDPASS_6K8K[513];
    extern Ipp32fc Syn_RefCopySam_6K8K[16384];
    extern Ipp32fc Syn_RefCopyAll_6K8K[8192];

#endif /* __PARAMETER_H */